<!--  -->
<template>
  <div class="qingwu">
    <div class="admin_main_block">
      <div>
        <el-form ref="form" :inline="true" :model="form" label-width="130px">
          <el-row>
            <h3>基本信息设置</h3>
            <el-col :span="8">
              <el-form-item label="服务名称">
                <el-input v-model="form.project_name" clearable />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="服务类型">
                <el-select
                  v-model="form.project_type"
                  clearable
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in serviceList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="服务描述" prop="introduction">
                <el-input
                  v-model="form.project_desc"
                  clearable
                  class="inp_wid"
                  type="textarea"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="商户名称">
                <el-input v-model="form.store_name" clearable />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="排序">
                <el-input v-model="form.sort" clearable />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="分类">
                <el-select v-model="form.cid" clearable placeholder="请选择">
                  <el-option
                    v-for="item in cidList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="关键词">
                <el-select
                  v-model="form.keywords_ids"
                  clearable
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in keywordList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="服务销量">
                <el-input v-model="form.project_sale_num_virtual" clearable />
              </el-form-item>
            </el-col>
          </el-row>
          <h3>价格设置</h3>
          <el-row>
            <el-col :span="8">
              <el-form-item label="价格类型">
                <el-select
                  v-model="form.project_price_type"
                  clearable
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in priceType"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="定金比例">
                <el-input v-model="form.project_deposit_ratio" clearable />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="用户价">
                <el-input v-model="form.project_user_price" clearable />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="会员价">
                <el-input v-model="form.project_member_price" clearable />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="用户定金">
                <el-input v-model="form.project_user_deposit" clearable />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="会员定金">
                <el-input v-model="form.project_member_deposit" clearable />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="16">
              <el-form-item label="分享可赚金额" prop="min_share_price">
                <el-input
                  v-model="form.min_share_price"
                  clearable
                /> </el-form-item
              >-
              <el-form-item prop="max_share_price">
                <el-input v-model="form.max_share_price" clearable />
              </el-form-item>
            </el-col>
          </el-row>
          <h3>奖励设置</h3>
          <el-row>
            <el-col :span="8">
              <el-form-item label="会员直推奖励">
                <el-input v-model="form.member_direct_reward" clearable />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="会员间推奖励">
                <el-input v-model="form.member_indirect_reawrd" clearable />
              </el-form-item>
            </el-col>
          </el-row>
          <h3>运营设置</h3>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="购买须知"
                class="width_auto_70"
                prop="purchase_notes"
              >
                <wangeditor
                  @goods_content="goods_content"
                  :id="'checkbuy'"
                  :contents="form.purchase_notes"
                ></wangeditor>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="项目主图" prop="project_images">
                <newUpload
                  ref="uploadImg"
                  :file-num="5"
                  :file-list="fileList"
                  :size-number="2"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="项目详情"
                class="width_auto_70"
                prop="project_content"
              >
                <wangeditor
                  @goods_content="goods_content1"
                  :id="'checkdetail'"
                  :contents="form.project_content"
                ></wangeditor>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <div>
              <el-button type="primary" @click="$router.go(-1)">返回</el-button>
              <el-button type="primary" @click="toChecked('form', 2)"
                >审核驳回</el-button
              >
              <el-button type="primary" @click="toChecked('form', 0)"
                >审核通过</el-button
              >
              <!-- <el-button type="primary" @click="toChecked('form')"
                >审核</el-button
              > -->
            </div>
          </el-row>
        </el-form>
      </div>
      <!-- 审核弹窗 -->
      <el-dialog
        title="审核"
        :visible.sync="centerDialogVisible"
        width="468px"
        @close="closeDialog"
      >
        <el-form
          ref="checkForm"
          :model="checkForm"
          :rules="checkRules"
          label-width="100px"
        >
          <el-form-item label="审核" prop="project_verify">
            <el-radio-group v-model="checkForm.project_verify">
              <el-radio label="0">通过</el-radio>
              <el-radio label="2">驳回</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item
            v-if="checkForm.project_verify == 2"
            label="驳回原因"
            prop="check_msg"
          >
            <el-input
              v-model="checkForm.project_verify_reason"
              placeholder="最多100个字符，超过字数限制不继续可输入"
              maxlength="100"
              clearable
              type="textarea"
              rows="4"
            />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="saveFn('checkForm')"
            >确 定</el-button
          >
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import wangeditor from "@/components/seller/wangeditor1.vue";
import wangeditorer from "@/components/seller/wangeditor1.vue";
import newUpload from "@/components/seller/shopImg.vue";
export default {
  components: {
    wangeditor,
    wangeditorer,
    newUpload,
  },
  data() {
    return {
      form: {
        id: "",
        project_name: "",
        project_type: "",
        project_desc: "",
        store_name: "",
        sort: "",
        cid: "",
        keywords_ids: "",
        project_sale_num_virtual: "",
        project_price: "",
        project_settlement_price: "",
        project_price_type: "",
        project_deposit_ratio: "",
        project_user_price: "",
        project_member_price: "",
        project_user_deposit: "",
        project_member_deposit: "",
        min_share_price: "",
        max_share_price: "",
        member_direct_reward: "",
        member_indirect_reawrd: "",
        purchase_notes: "",
        project_images: "",
        project_content: "",
        project_verify: "",
        // project_verify_reason: "",
      },
      serviceList: [], //服务类型
      cidList: [], //分类
      keywordList: [], //关键词
      priceType: [], //价格类型
      fileList: [],
      checkForm: {
        project_verify: "",
        project_verify_reason: "",
      },
      checkRules: {},
      centerDialogVisible: false,
    };
  },

  mounted() {
    this.getSelectList();
    this.form.id = this.$route.params.id;
    console.log("id", this.form.id);
  },

  methods: {
    // 获取下拉数据
    getSelectList() {
      this.$post(this.$api.projectCreate).then((res) => {
        if (res.code == 200) {
          this.cidList = res.data.projectClassArray;
          this.serviceList = res.data.projectTypeArray;
          this.keywordList = res.data.keywordArray;
          this.priceType = res.data.priceTypeArray;
        } else {
          this.$message.error(res.msg);
        }
      });
    },
    // 审核
    toChecked(form, opt) {
      // this.centerDialogVisible = true;
      this.form.project_verify = opt;
      this.form.project_images = this.$refs.uploadImg.submitUpload();
    },
    // 审核提交
    // saveFn() {},
    // 弹窗关闭
    closeDialog() {},
    // 富文本编辑内容变化
    goods_content: function (data) {
      // this.info.content = data;
      this.form.goods_content = data;
    },
    // 项目详情
    goods_content: function (data) {
      this.form.purchase_notes = data;
    },
    // 项目详情
    goods_content1(data) {
      this.form.project_content = data;
    },
  },
};
</script>
<style  scoped>
</style>